package com.yn.pet.controller.pc;


import com.yn.common.annotation.Anonymous;
import com.yn.common.core.domain.AjaxResult;
import com.yn.pet.bus.entity.DeviceSim;
import com.yn.pet.controller.pc.biz.DeviceSimBizService;
import com.yn.pet.controller.pc.request.DeviceSimRequest;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.Set;

/**
 * 设备SIM卡绑定表(DeviceSim)表控制层
 *
 * @author makejava
 * @since 2025-07-09 12:00:46
 */
@Anonymous
@RestController
@AllArgsConstructor
@RequestMapping("deviceSim")
public class DeviceSimController {

    private final DeviceSimBizService deviceSimBizService;

    @GetMapping("pageList")
    public AjaxResult pageList(DeviceSimRequest deviceSimRequest) {
        return AjaxResult.success(deviceSimBizService.pageList(deviceSimRequest));
    }

    @PostMapping("saveDeviceSim")
    public AjaxResult saveDeviceSim(@RequestBody DeviceSim deviceSim) {
        deviceSimBizService.saveDeviceSim(deviceSim);
        return AjaxResult.success();
    }

    @GetMapping("bindDeviceSim")
    public AjaxResult bindDeviceSim(@RequestParam Long deviceId, @RequestParam Long simId) {
        deviceSimBizService.bindDeviceSim(deviceId, simId);
        return AjaxResult.success();
    }

    @GetMapping("unBindDeviceSim")
    public AjaxResult unBindDeviceSim(@RequestParam Long simId) {
        deviceSimBizService.unBindDeviceSim(simId);
        return AjaxResult.success();
    }

    @GetMapping("removeDeviceSim")
    public AjaxResult removeDeviceSim(@RequestParam Set<Long> simIdSet) {
        deviceSimBizService.removeDeviceSim(simIdSet);
        return AjaxResult.success();
    }

    @PostMapping("importDeviceSim")
    public AjaxResult importDeviceSim(MultipartFile file) throws IOException {
        return AjaxResult.success(deviceSimBizService.importDeviceSim(file));
    }
}

